/*
 * voice.h
 *
 *		This file implements the wavetable oscillator, filter and
 *		amplitude envelope to create a 'voice' a complete unit of
 *		sound generation.
 *
 *      Author: Colin
 */

#ifndef VOICE_H_
#define VOICE_H_

#include <stdint.h>
#include <defs.h>
#include <Q16.h>
#include <wavetable.h>
#include <linear_interpolation.h>
#include <resfilter.h>
#include <envelope.h>

// voice state defines
#define noteOn 		0
#define noteOff 	1
#define voiceOff 	2

// update filter every 625 samples = 64 times a second
#define filterUpdateRate 625

// functions
void 	voice_init(void);
int32_t voice_update(void);
int32_t voice_state(void);
void 	voice_note_on(float frequency, float velocity);
void 	voice_note_on_continue(float frequency, float velocity);
void 	voice_note_off(void);
void 	voice_off();
void	voice_select_waveform(uint8_t controllerValue);
void	voice_amp_env_attack(uint8_t controllerValue);
void	voice_amp_env_decay(uint8_t controllerValue);
void	voice_amp_env_release(uint8_t controllerValue);
void 	voice_filter_resonance(uint8_t controllerValue);
void	voice_filter_env_attack(uint8_t controllerValue);
void	voice_filter_env_decay(uint8_t controllerValue);
void	voice_filter_env_release(uint8_t controllerValue);

#endif /* VOICE_H_ */
